$(function () {

    var packdata = JSON.parse($("body",parent.document).find("#packdata").val());
    var data = packdata;
    console.log(data)
    var video_url = data.video_url;//视频地址
    var video_poster = data.cover;//视频首图
    var video_title = data.title;//视频标题
    var video_label_name = data.label_name;//视频标签
    var video_detail = data.synopsis;//视频详情
    // var author_img = data.img;//作者头像
    var author_name = data.name;//作者姓名
    // var author_time = data.occupation;//发布时间
    var com_num = data.comment_num;//评论数
    var collect_num = data.follow_num;//收藏数
    var share_num = data.share_num;//分享数
    // if(com_num <= 0){
    //     com_num = "";
    // }
    var video_time = data.video_time;//视频时长，单位：s

    //写入视频
    var _videobox = $("#videobox");//视频盒子
    _videobox.append(
        '<video class="detailvideo-player" webkit-playsinline playsinline id="myvideo" poster="' + video_poster + '" width="100%" height="100%" controls="" preload="">' +
        '<source src="' + video_url + '" media="only screen and (min-device-width: 568px)">' +
        '<source src="' + video_url + '" media="only screen and (max-device-width: 568px)">' +
        '</video>'
    );

    //写入背景图
    $(".detailvideo-bg").attr({"style":"background: url(" + video_poster + ") no-repeat center; background-size: cover;"});

    //写入标题
    $(".detailvideo-title").html(video_title);

    //写入标签
    var _detailvideo_tagbox = $(".detailvideo-tagbox");//标签盒子
    _detailvideo_tagbox.empty();
    for(var i = 0; i < video_label_name.length; i++){
        _detailvideo_tagbox.append(
            '<div class="detailvideo-tag" data-id="' + video_label_name[i].id + '">' +
            '<span>' + video_label_name[i].label_name + '</span>' +
            '</div>'
        );
    }

    //写入详情
    $(".detailvideo-intro").text(video_detail);

    //作者姓名
    $(".detailvideo-name").text(author_name);

    //视频时长
    var video_time_min = parseInt(parseInt(video_time) / 60);//分数
    var video_time_sec = parseInt(video_time) % 60;//秒数
    if(video_time_sec.toString().length <= 1){
        video_time_sec = "0" + video_time_sec.toString();
    }
    $(".detailvideo-time").text(video_time_min + "′" + video_time_sec + "″");

    //评论总数
    var _detail_bottom_commentlist_num = $(".detail-bottom-commentlist-num");//弹窗评论总数盒子
    _detail_bottom_commentlist_num.text(com_num);
    $(".detailvideo-comment-num").text(com_num);
    if(com_num <= 0){
        _detail_bottom_commentlist_num.text("");
    }

    //收藏数
    $(".detailvideo-collect-num").text(collect_num);

    //分享数
    $(".detailvideo-share-num").text(share_num);

});